
import pymysql


class Mysql():

    def __init__(self):
        self.connect = pymysql.connect(host='localhost',user='root',password='root',database='school',charset='utf8')

    # 执行SQL语句
    def exec_edit(self,sql):
        with self.connect.cursor() as cursor:
            cursor.execute(sql)


    # 执行查询语句
    def get_data(self,sql):
        with self.connect.cursor() as cursor:
            cursor.execute(sql)
            result = cursor.fetchall()
            return result

    def close(self):
        self.close()



